package com.yueqian.Dao;

import com.yueqian.Utils.JDBCUtils;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class DeleteEmployeeDao {
    public static Boolean deleteEmployee(String  id){
        try {
            Connection connection = JDBCUtils.Connection();
            String sql = "delete from employee where number = ?";
            PreparedStatement preparedStatement = connection.prepareStatement(sql);
            preparedStatement.setString(1, id);
            int i = preparedStatement.executeUpdate();
            if (i > 0) {
                System.out.println("删除成功");
                return true;
            } else {
                System.out.println("用户不存在");
                System.out.println("删除失败");
                return false;
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }


    }
}
